IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_lokalenFlipover' AND xtype='P') 
BEGIN
	DROP PROCEDURE WEB_lokalenFlipover
END
GO

CREATE   procedure WEB_lokalenFlipover
as
set nocount on

select '0AAAA' as lokaal,0 as lokaalNr,'<?xml version="1.0"  encoding="ISO-8859-1" ?><lokalen>' as tekst
union
select distinct left(lokalen,1) as lokaal,0,'<begin>'
from leraars..lokalenVolgorde
union
select distinct isNull(Lokalen,'WWWWW'),volgnr,'<lokaal naam="' + isnull(lokalen,'-') + '" soort="' + isnull(omschrijving,'-')+ '" projector="' + isnull(projector,'-')+ '" projectiescherm="' + isnull(projectiescherm,'-')+ '"
				netwerk="' + isnull(netwerk,'-') + '"
 		                tv="' + isnull(tv,'-') + '"
				video="' + isnull(video,'-') + '"
				dvd="' + isnull(dvd,'-') + '"
				pc="' + isnull(pc,'-')+ '"
                                tafels="' + isnull(convert(varchar(2),tafels),'-') + '"
                                stoelen="' + isnull(convert(varchar(2),stoelen),'-') +'"
				stopcontacten="' + isnull(convert(varchar(2),stopcontacten),'-') +'"
 	                        paneeltype="' + isnull(paneeltype,'-') +'"
 >' + isNull(rtrim(Lokalen),'') +
				

 '</lokaal>'
from lokalenvolgorde
union
select 'ZZZZZ',0,'</lokalen>'
union
select distinct left(lokalen,1)+'999','999','</begin>'
from leraars..lokalenVolgorde
order by lokaal,lokaalNr